﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;



namespace TestApp1
{
    public partial class Form1 : Form
    {
        private int x = 0;

        public Form1()
        {
            InitializeComponent();

            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            this.timer1.Start();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.label1.Text = "Oh, you pushed the button";
        }


        private void Form1_Paint_1(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Image img = new Bitmap(@"..\..\images\jag.JPG");

            Rectangle rect = new Rectangle(50, 30, 100, 100);
            LinearGradientBrush lBrush = new LinearGradientBrush(rect, Color.Red, Color.Yellow, LinearGradientMode.BackwardDiagonal);
            g.FillRectangle(lBrush, rect);

            g.DrawImageUnscaled(img, new Point(x, 100));

            x++;

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Invalidate(true);
        }


    }
}
